{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "accompanied-pakistan",
   "metadata": {},
   "source": [
    "# Variadic lines in `geomPath()` and `geomLine()`\n",
    "\n",
    "Using `size` and `color` aesthetics in the mapping of `geomPath` or `geomLine`\\\n",
    "may lead to variadic width or/and color of lines, depending on the data."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "after-treasurer",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"QanVhW\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"library\">\n",
       "       if(!window.letsPlotCallQueue) {\n",
       "           window.letsPlotCallQueue = [];\n",
       "       }; \n",
       "       window.letsPlotCall = function(f) {\n",
       "           window.letsPlotCallQueue.push(f);\n",
       "       };\n",
       "       (function() {\n",
       "           var script = document.createElement(\"script\");\n",
       "           script.type = \"text/javascript\";\n",
       "           script.src = \"https://cdn.jsdelivr.net/gh/JetBrains/lets-plot@v4.0.0/js-package/distr/lets-plot.min.js\";\n",
       "           script.onload = function() {\n",
       "               window.letsPlotCall = function(f) {f();};\n",
       "               window.letsPlotCallQueue.forEach(function(f) {f();});\n",
       "               window.letsPlotCallQueue = [];\n",
       "               \n",
       "               \n",
       "           };\n",
       "           script.onerror = function(event) {\n",
       "               window.letsPlotCall = function(f) {};\n",
       "               window.letsPlotCallQueue = [];\n",
       "               var div = document.createElement(\"div\");\n",
       "               div.style.color = 'darkred';\n",
       "               div.textContent = 'Error loading Lets-Plot JS';\n",
       "               document.getElementById(\"QanVhW\").appendChild(div);\n",
       "           };\n",
       "           var e = document.getElementById(\"QanVhW\");\n",
       "           e.appendChild(script);\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "            <div id=\"kotlin_out_0\"/>\n",
       "            <script type=\"text/javascript\">\n",
       "                            if(!window.kotlinQueues) {\n",
       "                window.kotlinQueues = {};\n",
       "            }\n",
       "            if(!window.kotlinQueues[\"DataFrame\"]) {\n",
       "                var resQueue = [];\n",
       "                window.kotlinQueues[\"DataFrame\"] = resQueue;\n",
       "                window[\"call_DataFrame\"] = function(f) {\n",
       "                    resQueue.push(f);\n",
       "                }\n",
       "            }\n",
       "            (function (){\n",
       "                var modifiers = [(function(script) {\n",
       "    script.src = \"https://cdn.jsdelivr.net/gh/Kotlin/dataframe@3db46ccccaa1291c0627307d64133317f545e6ae/core/src/main/resources/init.js\"\n",
       "    script.type = \"text/javascript\";\n",
       "})];\n",
       "                var e = document.getElementById(\"kotlin_out_0\");\n",
       "                modifiers.forEach(function (gen) {\n",
       "                    var script = document.createElement(\"script\");\n",
       "                    gen(script)\n",
       "                    script.addEventListener(\"load\", function() {\n",
       "                        window[\"call_DataFrame\"] = function(f) {f();};\n",
       "                        window.kotlinQueues[\"DataFrame\"].forEach(function(f) {f();});\n",
       "                        window.kotlinQueues[\"DataFrame\"] = [];\n",
       "                    }, false);\n",
       "                    script.addEventListener(\"error\", function() {\n",
       "                        window[\"call_DataFrame\"] = function(f) {};\n",
       "                        window.kotlinQueues[\"DataFrame\"] = [];\n",
       "                        var div = document.createElement(\"div\");\n",
       "                        div.style.color = 'darkred';\n",
       "                        div.textContent = 'Error loading resource DataFrame';\n",
       "                        document.getElementById(\"kotlin_out_0\").appendChild(div);\n",
       "                    }, false);\n",
       "                    \n",
       "                    e.appendChild(script);\n",
       "                });\n",
       "            })();\n",
       "            </script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "                <style>\n",
       "                :root {\n",
       "    --background: #fff;\n",
       "    --background-odd: #f5f5f5;\n",
       "    --background-hover: #d9edfd;\n",
       "    --header-text-color: #474747;\n",
       "    --text-color: #848484;\n",
       "    --text-color-dark: #000;\n",
       "    --text-color-medium: #737373;\n",
       "    --text-color-pale: #b3b3b3;\n",
       "    --inner-border-color: #aaa;\n",
       "    --bold-border-color: #000;\n",
       "    --link-color: #296eaa;\n",
       "    --link-color-pale: #296eaa;\n",
       "    --link-hover: #1a466c;\n",
       "}\n",
       "\n",
       ":root[theme=\"dark\"], :root [data-jp-theme-light=\"false\"], .dataframe_dark{\n",
       "    --background: #303030;\n",
       "    --background-odd: #3c3c3c;\n",
       "    --background-hover: #464646;\n",
       "    --header-text-color: #dddddd;\n",
       "    --text-color: #b3b3b3;\n",
       "    --text-color-dark: #dddddd;\n",
       "    --text-color-medium: #b2b2b2;\n",
       "    --text-color-pale: #737373;\n",
       "    --inner-border-color: #707070;\n",
       "    --bold-border-color: #777777;\n",
       "    --link-color: #008dc0;\n",
       "    --link-color-pale: #97e1fb;\n",
       "    --link-hover: #00688e;\n",
       "}\n",
       "\n",
       "p.dataframe_description {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe {\n",
       "    font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n",
       "    font-size: 12px;\n",
       "    background-color: var(--background);\n",
       "    color: var(--text-color-dark);\n",
       "    border: none;\n",
       "    border-collapse: collapse;\n",
       "}\n",
       "\n",
       "table.dataframe th, td {\n",
       "    padding: 6px;\n",
       "    border: 1px solid transparent;\n",
       "    text-align: left;\n",
       "}\n",
       "\n",
       "table.dataframe th {\n",
       "    background-color: var(--background);\n",
       "    color: var(--header-text-color);\n",
       "}\n",
       "\n",
       "table.dataframe td {\n",
       "    vertical-align: top;\n",
       "}\n",
       "\n",
       "table.dataframe th.bottomBorder {\n",
       "    border-bottom-color: var(--bold-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:nth-child(odd) {\n",
       "    background: var(--background-odd);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:nth-child(even) {\n",
       "    background: var(--background);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:hover {\n",
       "    background: var(--background-hover);\n",
       "}\n",
       "\n",
       "table.dataframe a {\n",
       "    cursor: pointer;\n",
       "    color: var(--link-color);\n",
       "    text-decoration: none;\n",
       "}\n",
       "\n",
       "table.dataframe tr:hover > td a {\n",
       "    color: var(--link-color-pale);\n",
       "}\n",
       "\n",
       "table.dataframe a:hover {\n",
       "    color: var(--link-hover);\n",
       "    text-decoration: underline;\n",
       "}\n",
       "\n",
       "table.dataframe img {\n",
       "    max-width: fit-content;\n",
       "}\n",
       "\n",
       "table.dataframe th.complex {\n",
       "    background-color: var(--background);\n",
       "    border: 1px solid var(--background);\n",
       "}\n",
       "\n",
       "table.dataframe .leftBorder {\n",
       "    border-left-color: var(--inner-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe .rightBorder {\n",
       "    border-right-color: var(--inner-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe .rightAlign {\n",
       "    text-align: right;\n",
       "}\n",
       "\n",
       "table.dataframe .expanderSvg {\n",
       "    width: 8px;\n",
       "    height: 8px;\n",
       "    margin-right: 3px;\n",
       "}\n",
       "\n",
       "table.dataframe .expander {\n",
       "    display: flex;\n",
       "    align-items: center;\n",
       "}\n",
       "\n",
       "/* formatting */\n",
       "\n",
       "table.dataframe .null {\n",
       "    color: var(--text-color-pale);\n",
       "}\n",
       "\n",
       "table.dataframe .structural {\n",
       "    color: var(--text-color-medium);\n",
       "    font-weight: bold;\n",
       "}\n",
       "\n",
       "table.dataframe .dataFrameCaption {\n",
       "    font-weight: bold;\n",
       "}\n",
       "\n",
       "table.dataframe .numbers {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe td:hover .formatted .structural, .null {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe tr:hover .formatted .structural, .null {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "\n",
       "                </style>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%useLatestDescriptors\n",
    "%use lets-plot\n",
    "%use dataframe"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "computational-latex",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Lets-Plot Kotlin API v.4.4.2. Frontend: Notebook with dynamically loaded JS. Lets-Plot JS v.4.0.0."
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "LetsPlot.getInfo()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "hungarian-detroit",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/kotlindataframe+json": "{\"nrow\":3,\"ncol\":7,\"columns\":[\"untitled\",\"Ozone\",\"Solar.R\",\"Wind\",\"Temp\",\"Month\",\"Day\"],\"kotlin_dataframe\":[{\"untitled\":1,\"Ozone\":41,\"Solar.R\":190,\"Wind\":7.4,\"Temp\":67,\"Month\":5,\"Day\":1},{\"untitled\":2,\"Ozone\":36,\"Solar.R\":118,\"Wind\":8.0,\"Temp\":72,\"Month\":5,\"Day\":2},{\"untitled\":3,\"Ozone\":12,\"Solar.R\":149,\"Wind\":12.6,\"Temp\":74,\"Month\":5,\"Day\":3}]}",
      "text/html": [
       "        <html>\n",
       "        <head>\n",
       "            <style type=\"text/css\">\n",
       "                :root {\n",
       "    --background: #fff;\n",
       "    --background-odd: #f5f5f5;\n",
       "    --background-hover: #d9edfd;\n",
       "    --header-text-color: #474747;\n",
       "    --text-color: #848484;\n",
       "    --text-color-dark: #000;\n",
       "    --text-color-medium: #737373;\n",
       "    --text-color-pale: #b3b3b3;\n",
       "    --inner-border-color: #aaa;\n",
       "    --bold-border-color: #000;\n",
       "    --link-color: #296eaa;\n",
       "    --link-color-pale: #296eaa;\n",
       "    --link-hover: #1a466c;\n",
       "}\n",
       "\n",
       ":root[theme=\"dark\"], :root [data-jp-theme-light=\"false\"], .dataframe_dark{\n",
       "    --background: #303030;\n",
       "    --background-odd: #3c3c3c;\n",
       "    --background-hover: #464646;\n",
       "    --header-text-color: #dddddd;\n",
       "    --text-color: #b3b3b3;\n",
       "    --text-color-dark: #dddddd;\n",
       "    --text-color-medium: #b2b2b2;\n",
       "    --text-color-pale: #737373;\n",
       "    --inner-border-color: #707070;\n",
       "    --bold-border-color: #777777;\n",
       "    --link-color: #008dc0;\n",
       "    --link-color-pale: #97e1fb;\n",
       "    --link-hover: #00688e;\n",
       "}\n",
       "\n",
       "p.dataframe_description {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe {\n",
       "    font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n",
       "    font-size: 12px;\n",
       "    background-color: var(--background);\n",
       "    color: var(--text-color-dark);\n",
       "    border: none;\n",
       "    border-collapse: collapse;\n",
       "}\n",
       "\n",
       "table.dataframe th, td {\n",
       "    padding: 6px;\n",
       "    border: 1px solid transparent;\n",
       "    text-align: left;\n",
       "}\n",
       "\n",
       "table.dataframe th {\n",
       "    background-color: var(--background);\n",
       "    color: var(--header-text-color);\n",
       "}\n",
       "\n",
       "table.dataframe td {\n",
       "    vertical-align: top;\n",
       "}\n",
       "\n",
       "table.dataframe th.bottomBorder {\n",
       "    border-bottom-color: var(--bold-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:nth-child(odd) {\n",
       "    background: var(--background-odd);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:nth-child(even) {\n",
       "    background: var(--background);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:hover {\n",
       "    background: var(--background-hover);\n",
       "}\n",
       "\n",
       "table.dataframe a {\n",
       "    cursor: pointer;\n",
       "    color: var(--link-color);\n",
       "    text-decoration: none;\n",
       "}\n",
       "\n",
       "table.dataframe tr:hover > td a {\n",
       "    color: var(--link-color-pale);\n",
       "}\n",
       "\n",
       "table.dataframe a:hover {\n",
       "    color: var(--link-hover);\n",
       "    text-decoration: underline;\n",
       "}\n",
       "\n",
       "table.dataframe img {\n",
       "    max-width: fit-content;\n",
       "}\n",
       "\n",
       "table.dataframe th.complex {\n",
       "    background-color: var(--background);\n",
       "    border: 1px solid var(--background);\n",
       "}\n",
       "\n",
       "table.dataframe .leftBorder {\n",
       "    border-left-color: var(--inner-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe .rightBorder {\n",
       "    border-right-color: var(--inner-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe .rightAlign {\n",
       "    text-align: right;\n",
       "}\n",
       "\n",
       "table.dataframe .expanderSvg {\n",
       "    width: 8px;\n",
       "    height: 8px;\n",
       "    margin-right: 3px;\n",
       "}\n",
       "\n",
       "table.dataframe .expander {\n",
       "    display: flex;\n",
       "    align-items: center;\n",
       "}\n",
       "\n",
       "/* formatting */\n",
       "\n",
       "table.dataframe .null {\n",
       "    color: var(--text-color-pale);\n",
       "}\n",
       "\n",
       "table.dataframe .structural {\n",
       "    color: var(--text-color-medium);\n",
       "    font-weight: bold;\n",
       "}\n",
       "\n",
       "table.dataframe .dataFrameCaption {\n",
       "    font-weight: bold;\n",
       "}\n",
       "\n",
       "table.dataframe .numbers {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe td:hover .formatted .structural, .null {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe tr:hover .formatted .structural, .null {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "            </style>\n",
       "        </head>\n",
       "        <body>\n",
       "            \n",
       "<table class=\"dataframe\" id=\"df_-1660944384\"></table>\n",
       "\n",
       "<p class=\"dataframe_description\">DataFrame: rowsCount = 3, columnsCount = 7</p>\n",
       "        </body>\n",
       "        <script>\n",
       "            \n",
       "/*<!--*/\n",
       "call_DataFrame(function() { DataFrame.addTable({ cols: [{ name: \"<span title=\\\"untitled: Int\\\">untitled</span>\", children: [], rightAlign: true, values: [\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">1</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">2</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">3</span></span>\"] }, \n",
       "{ name: \"<span title=\\\"Ozone: Int\\\">Ozone</span>\", children: [], rightAlign: true, values: [\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">41</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">36</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">12</span></span>\"] }, \n",
       "{ name: \"<span title=\\\"Solar.R: Int\\\">Solar.R</span>\", children: [], rightAlign: true, values: [\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">190</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">118</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">149</span></span>\"] }, \n",
       "{ name: \"<span title=\\\"Wind: Double\\\">Wind</span>\", children: [], rightAlign: true, values: [\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">7.4</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">8.0</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">12.6</span></span>\"] }, \n",
       "{ name: \"<span title=\\\"Temp: Int\\\">Temp</span>\", children: [], rightAlign: true, values: [\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">67</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">72</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">74</span></span>\"] }, \n",
       "{ name: \"<span title=\\\"Month: Int\\\">Month</span>\", children: [], rightAlign: true, values: [\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">5</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">5</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">5</span></span>\"] }, \n",
       "{ name: \"<span title=\\\"Day: Int\\\">Day</span>\", children: [], rightAlign: true, values: [\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">1</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">2</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">3</span></span>\"] }, \n",
       "], id: -1660944384, rootId: -1660944384, totalRows: 3 } ) });\n",
       "/*-->*/\n",
       "\n",
       "call_DataFrame(function() { DataFrame.renderTable(-1660944384) });\n",
       "\n",
       "\n",
       "        </script>\n",
       "        </html>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "val df = DataFrame.readCSV(\"https://raw.githubusercontent.com/vincentarelbundock/Rdatasets/master/csv/datasets/airquality.csv\")\n",
    "df.head(3)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "boolean-rating",
   "metadata": {},
   "source": [
    "#### 1. Variable Line Width"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "protective-barbados",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"Q2TunA\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "\"Month\":[5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0],\n",
       "\"Wind\":[7.4,8.0,12.6,11.5,14.3,14.9,8.6,13.8,20.1,8.6,6.9,9.7,9.2,10.9,13.2,11.5,12.0,18.4,11.5,9.7,9.7,16.6,9.7,12.0,16.6,14.9,8.0,12.0,14.9,5.7,7.4,8.6,9.7,16.1,9.2,8.6,14.3,9.7,6.9,13.8,11.5,10.9,9.2,8.0,13.8,11.5,14.9,20.7,9.2,11.5,10.3,6.3,1.7,4.6,6.3,8.0,8.0,10.3,11.5,14.9,8.0,4.1,9.2,9.2,10.9,4.6,10.9,5.1,6.3,5.7,7.4,8.6,14.3,14.9,14.9,14.3,6.9,10.3,6.3,5.1,11.5,6.9,9.7,11.5,8.6,8.0,8.6,12.0,7.4,7.4,7.4,9.2,6.9,13.8,7.4,6.9,7.4,4.6,4.0,10.3,8.0,8.6,11.5,11.5,11.5,9.7,11.5,10.3,6.3,7.4,10.9,10.3,15.5,14.3,12.6,9.7,3.4,8.0,5.7,9.7,2.3,6.3,6.3,6.9,5.1,2.8,4.6,7.4,15.5,10.9,10.3,10.9,9.7,14.9,15.5,6.3,10.9,11.5,6.9,13.8,10.3,10.3,8.0,12.6,9.2,10.3,10.3,16.6,6.9,13.2,14.3,8.0,11.5],\n",
       "\"Temp\":[67.0,72.0,74.0,62.0,56.0,66.0,65.0,59.0,61.0,69.0,74.0,69.0,66.0,68.0,58.0,64.0,66.0,57.0,68.0,62.0,59.0,73.0,61.0,61.0,57.0,58.0,57.0,67.0,81.0,79.0,76.0,78.0,74.0,67.0,84.0,85.0,79.0,82.0,87.0,90.0,87.0,93.0,92.0,82.0,80.0,79.0,77.0,72.0,65.0,73.0,76.0,77.0,76.0,76.0,76.0,75.0,78.0,73.0,80.0,77.0,83.0,84.0,85.0,81.0,84.0,83.0,83.0,88.0,92.0,92.0,89.0,82.0,73.0,81.0,91.0,80.0,81.0,82.0,84.0,87.0,85.0,74.0,81.0,82.0,86.0,85.0,82.0,86.0,88.0,86.0,83.0,81.0,81.0,81.0,82.0,86.0,85.0,87.0,89.0,90.0,90.0,92.0,86.0,86.0,82.0,80.0,79.0,77.0,79.0,76.0,78.0,78.0,77.0,72.0,75.0,79.0,81.0,86.0,88.0,97.0,94.0,96.0,94.0,91.0,92.0,93.0,93.0,87.0,84.0,80.0,78.0,75.0,73.0,81.0,76.0,77.0,71.0,71.0,78.0,67.0,76.0,68.0,82.0,64.0,71.0,81.0,69.0,63.0,70.0,77.0,75.0,76.0,68.0],\n",
       "\"Day\":[1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0,25.0,26.0,27.0,28.0,29.0,30.0,31.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0,25.0,26.0,27.0,28.0,29.0,30.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0,25.0,26.0,27.0,28.0,29.0,30.0,31.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0,25.0,26.0,27.0,28.0,29.0,30.0,31.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0,25.0,26.0,27.0,28.0,29.0,30.0]\n",
       "},\n",
       "\"ggsize\":{\n",
       "\"width\":700.0,\n",
       "\"height\":500.0\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"size\",\n",
       "\"range\":[0.5,5.0]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "\"x\":\"Day\",\n",
       "\"y\":\"Temp\",\n",
       "\"color\":\"Month\",\n",
       "\"size\":\"Wind\"\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"line\",\n",
       "\"data_meta\":{\n",
       "\"mapping_annotations\":[{\n",
       "\"aes\":\"color\",\n",
       "\"annotation\":\"as_discrete\",\n",
       "\"parameters\":{\n",
       "\"label\":\"Month\"\n",
       "}\n",
       "}]\n",
       "},\n",
       "\"data\":{\n",
       "}\n",
       "}]\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"Q2TunA\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();    \n",
       "   </script>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "letsPlot(df.toMap()) +\n",
    "    geomLine() {\n",
    "        x = \"Day\"\n",
    "        y = \"Temp\"\n",
    "        size = \"Wind\"   // <--- wind varies by day\n",
    "        color = asDiscrete(\"Month\")        \n",
    "    } +\n",
    "    scaleSize(Pair(0.5, 5.0)) +\n",
    "    ggsize(700, 500)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "unauthorized-surname",
   "metadata": {},
   "source": [
    "#### 2. Variable Line Color"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "grateful-emerald",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"tnDgE1\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "\"Month\":[5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0],\n",
       "\"Wind\":[7.4,8.0,12.6,11.5,14.3,14.9,8.6,13.8,20.1,8.6,6.9,9.7,9.2,10.9,13.2,11.5,12.0,18.4,11.5,9.7,9.7,16.6,9.7,12.0,16.6,14.9,8.0,12.0,14.9,5.7,7.4,8.6,9.7,16.1,9.2,8.6,14.3,9.7,6.9,13.8,11.5,10.9,9.2,8.0,13.8,11.5,14.9,20.7,9.2,11.5,10.3,6.3,1.7,4.6,6.3,8.0,8.0,10.3,11.5,14.9,8.0,4.1,9.2,9.2,10.9,4.6,10.9,5.1,6.3,5.7,7.4,8.6,14.3,14.9,14.9,14.3,6.9,10.3,6.3,5.1,11.5,6.9,9.7,11.5,8.6,8.0,8.6,12.0,7.4,7.4,7.4,9.2,6.9,13.8,7.4,6.9,7.4,4.6,4.0,10.3,8.0,8.6,11.5,11.5,11.5,9.7,11.5,10.3,6.3,7.4,10.9,10.3,15.5,14.3,12.6,9.7,3.4,8.0,5.7,9.7,2.3,6.3,6.3,6.9,5.1,2.8,4.6,7.4,15.5,10.9,10.3,10.9,9.7,14.9,15.5,6.3,10.9,11.5,6.9,13.8,10.3,10.3,8.0,12.6,9.2,10.3,10.3,16.6,6.9,13.2,14.3,8.0,11.5],\n",
       "\"Temp\":[67.0,72.0,74.0,62.0,56.0,66.0,65.0,59.0,61.0,69.0,74.0,69.0,66.0,68.0,58.0,64.0,66.0,57.0,68.0,62.0,59.0,73.0,61.0,61.0,57.0,58.0,57.0,67.0,81.0,79.0,76.0,78.0,74.0,67.0,84.0,85.0,79.0,82.0,87.0,90.0,87.0,93.0,92.0,82.0,80.0,79.0,77.0,72.0,65.0,73.0,76.0,77.0,76.0,76.0,76.0,75.0,78.0,73.0,80.0,77.0,83.0,84.0,85.0,81.0,84.0,83.0,83.0,88.0,92.0,92.0,89.0,82.0,73.0,81.0,91.0,80.0,81.0,82.0,84.0,87.0,85.0,74.0,81.0,82.0,86.0,85.0,82.0,86.0,88.0,86.0,83.0,81.0,81.0,81.0,82.0,86.0,85.0,87.0,89.0,90.0,90.0,92.0,86.0,86.0,82.0,80.0,79.0,77.0,79.0,76.0,78.0,78.0,77.0,72.0,75.0,79.0,81.0,86.0,88.0,97.0,94.0,96.0,94.0,91.0,92.0,93.0,93.0,87.0,84.0,80.0,78.0,75.0,73.0,81.0,76.0,77.0,71.0,71.0,78.0,67.0,76.0,68.0,82.0,64.0,71.0,81.0,69.0,63.0,70.0,77.0,75.0,76.0,68.0],\n",
       "\"Day\":[1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0,25.0,26.0,27.0,28.0,29.0,30.0,31.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0,25.0,26.0,27.0,28.0,29.0,30.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0,25.0,26.0,27.0,28.0,29.0,30.0,31.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0,25.0,26.0,27.0,28.0,29.0,30.0,31.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0,25.0,26.0,27.0,28.0,29.0,30.0]\n",
       "},\n",
       "\"ggsize\":{\n",
       "\"width\":700.0,\n",
       "\"height\":500.0\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"color\",\n",
       "\"scale_mapper_kind\":\"color_gradient\",\n",
       "\"high\":\"#d7191c\",\n",
       "\"low\":\"#1a9641\"\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "\"x\":\"Day\",\n",
       "\"y\":\"Temp\",\n",
       "\"color\":\"Wind\",\n",
       "\"group\":\"Month\"\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"size\":2.0,\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"line\",\n",
       "\"data\":{\n",
       "}\n",
       "}]\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"tnDgE1\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();    \n",
       "   </script>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "letsPlot(df.toMap()) +\n",
    "    geomLine(size = 2) {\n",
    "        x = \"Day\"\n",
    "        y = \"Temp\"\n",
    "        color = \"Wind\"   // <--- wind varies by day\n",
    "        group = \"Month\"\n",
    "    } +\n",
    "    scaleColorGradient(low=\"#1a9641\", high=\"#d7191c\") +\n",
    "    ggsize(700, 500)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "headed-cliff",
   "metadata": {},
   "source": [
    "#### 3. Variable both, Line Color and Width"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "enhanced-presentation",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"1QBoDD\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "\"Wind\":[7.4,8.0,12.6,11.5,14.3,14.9,8.6,13.8,20.1,8.6,6.9,9.7,9.2,10.9,13.2,11.5,12.0,18.4,11.5,9.7,9.7,16.6,9.7,12.0,16.6,14.9,8.0,12.0,14.9,5.7,7.4,8.6,9.7,16.1,9.2,8.6,14.3,9.7,6.9,13.8,11.5,10.9,9.2,8.0,13.8,11.5,14.9,20.7,9.2,11.5,10.3,6.3,1.7,4.6,6.3,8.0,8.0,10.3,11.5,14.9,8.0,4.1,9.2,9.2,10.9,4.6,10.9,5.1,6.3,5.7,7.4,8.6,14.3,14.9,14.9,14.3,6.9,10.3,6.3,5.1,11.5,6.9,9.7,11.5,8.6,8.0,8.6,12.0,7.4,7.4,7.4,9.2,6.9,13.8,7.4,6.9,7.4,4.6,4.0,10.3,8.0,8.6,11.5,11.5,11.5,9.7,11.5,10.3,6.3,7.4,10.9,10.3,15.5,14.3,12.6,9.7,3.4,8.0,5.7,9.7,2.3,6.3,6.3,6.9,5.1,2.8,4.6,7.4,15.5,10.9,10.3,10.9,9.7,14.9,15.5,6.3,10.9,11.5,6.9,13.8,10.3,10.3,8.0,12.6,9.2,10.3,10.3,16.6,6.9,13.2,14.3,8.0,11.5],\n",
       "\"Month\":[5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0],\n",
       "\"Temp\":[67.0,72.0,74.0,62.0,56.0,66.0,65.0,59.0,61.0,69.0,74.0,69.0,66.0,68.0,58.0,64.0,66.0,57.0,68.0,62.0,59.0,73.0,61.0,61.0,57.0,58.0,57.0,67.0,81.0,79.0,76.0,78.0,74.0,67.0,84.0,85.0,79.0,82.0,87.0,90.0,87.0,93.0,92.0,82.0,80.0,79.0,77.0,72.0,65.0,73.0,76.0,77.0,76.0,76.0,76.0,75.0,78.0,73.0,80.0,77.0,83.0,84.0,85.0,81.0,84.0,83.0,83.0,88.0,92.0,92.0,89.0,82.0,73.0,81.0,91.0,80.0,81.0,82.0,84.0,87.0,85.0,74.0,81.0,82.0,86.0,85.0,82.0,86.0,88.0,86.0,83.0,81.0,81.0,81.0,82.0,86.0,85.0,87.0,89.0,90.0,90.0,92.0,86.0,86.0,82.0,80.0,79.0,77.0,79.0,76.0,78.0,78.0,77.0,72.0,75.0,79.0,81.0,86.0,88.0,97.0,94.0,96.0,94.0,91.0,92.0,93.0,93.0,87.0,84.0,80.0,78.0,75.0,73.0,81.0,76.0,77.0,71.0,71.0,78.0,67.0,76.0,68.0,82.0,64.0,71.0,81.0,69.0,63.0,70.0,77.0,75.0,76.0,68.0],\n",
       "\"Ozone\":[41.0,36.0,12.0,18.0,null,28.0,23.0,19.0,8.0,null,7.0,16.0,11.0,14.0,18.0,14.0,34.0,6.0,30.0,11.0,1.0,11.0,4.0,32.0,null,null,null,23.0,45.0,115.0,37.0,null,null,null,null,null,null,29.0,null,71.0,39.0,null,null,23.0,null,null,21.0,37.0,20.0,12.0,13.0,null,null,null,null,null,null,null,null,null,null,135.0,49.0,32.0,null,64.0,40.0,77.0,97.0,97.0,85.0,null,10.0,27.0,null,7.0,48.0,35.0,61.0,79.0,63.0,16.0,null,null,80.0,108.0,20.0,52.0,82.0,50.0,64.0,59.0,39.0,9.0,16.0,78.0,35.0,66.0,122.0,89.0,110.0,null,null,44.0,28.0,65.0,null,22.0,59.0,23.0,31.0,44.0,21.0,9.0,null,45.0,168.0,73.0,null,76.0,118.0,84.0,85.0,96.0,78.0,73.0,91.0,47.0,32.0,20.0,23.0,21.0,24.0,44.0,21.0,28.0,9.0,13.0,46.0,18.0,13.0,24.0,16.0,13.0,23.0,36.0,7.0,14.0,30.0,null,14.0,18.0,20.0],\n",
       "\"Day\":[1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0,25.0,26.0,27.0,28.0,29.0,30.0,31.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0,25.0,26.0,27.0,28.0,29.0,30.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0,25.0,26.0,27.0,28.0,29.0,30.0,31.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0,25.0,26.0,27.0,28.0,29.0,30.0,31.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0,25.0,26.0,27.0,28.0,29.0,30.0]\n",
       "},\n",
       "\"ggsize\":{\n",
       "\"width\":700.0,\n",
       "\"height\":500.0\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"size\",\n",
       "\"range\":[0.5,5.0]\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"scale_mapper_kind\":\"color_brewer\",\n",
       "\"palette\":\"RdYlGn\",\n",
       "\"direction\":-1.0\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "\"x\":\"Day\",\n",
       "\"y\":\"Temp\",\n",
       "\"color\":\"Ozone\",\n",
       "\"size\":\"Wind\",\n",
       "\"group\":\"Month\"\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"line\",\n",
       "\"data\":{\n",
       "}\n",
       "}]\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"1QBoDD\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();    \n",
       "   </script>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "letsPlot(df.toMap()) +\n",
    "    geomLine {\n",
    "        x = \"Day\"\n",
    "        y = \"Temp\"\n",
    "        color = \"Ozone\" // <--- ozone varies by day and sometimes n/a\n",
    "        size = \"Wind\"   // <--- wind varies by day\n",
    "        group = \"Month\"\n",
    "    } +\n",
    "    scaleSize(Pair(0.5, 5)) +\n",
    "    scaleColorBrewer(palette = \"RdYlGn\", direction = -1) +\n",
    "    ggsize(700, 500)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "vulnerable-romantic",
   "metadata": {},
   "source": [
    "#### 4. The Minard Map (simplified)\n",
    "\n",
    "The orirnal can be found here: https://en.wikipedia.org/wiki/Charles_Joseph_Minard#The_map_of_Napoleon's_Russian_campaign"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "aggregate-maine",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/kotlindataframe+json": "{\"nrow\":3,\"ncol\":6,\"columns\":[\"untitled\",\"long\",\"lat\",\"survivors\",\"direction\",\"group\"],\"kotlin_dataframe\":[{\"untitled\":1,\"long\":24.0,\"lat\":54.9,\"survivors\":340000,\"direction\":\"A\",\"group\":1},{\"untitled\":2,\"long\":24.5,\"lat\":55.0,\"survivors\":340000,\"direction\":\"A\",\"group\":1},{\"untitled\":3,\"long\":25.5,\"lat\":54.5,\"survivors\":340000,\"direction\":\"A\",\"group\":1}]}",
      "text/html": [
       "        <html>\n",
       "        <head>\n",
       "            <style type=\"text/css\">\n",
       "                :root {\n",
       "    --background: #fff;\n",
       "    --background-odd: #f5f5f5;\n",
       "    --background-hover: #d9edfd;\n",
       "    --header-text-color: #474747;\n",
       "    --text-color: #848484;\n",
       "    --text-color-dark: #000;\n",
       "    --text-color-medium: #737373;\n",
       "    --text-color-pale: #b3b3b3;\n",
       "    --inner-border-color: #aaa;\n",
       "    --bold-border-color: #000;\n",
       "    --link-color: #296eaa;\n",
       "    --link-color-pale: #296eaa;\n",
       "    --link-hover: #1a466c;\n",
       "}\n",
       "\n",
       ":root[theme=\"dark\"], :root [data-jp-theme-light=\"false\"], .dataframe_dark{\n",
       "    --background: #303030;\n",
       "    --background-odd: #3c3c3c;\n",
       "    --background-hover: #464646;\n",
       "    --header-text-color: #dddddd;\n",
       "    --text-color: #b3b3b3;\n",
       "    --text-color-dark: #dddddd;\n",
       "    --text-color-medium: #b2b2b2;\n",
       "    --text-color-pale: #737373;\n",
       "    --inner-border-color: #707070;\n",
       "    --bold-border-color: #777777;\n",
       "    --link-color: #008dc0;\n",
       "    --link-color-pale: #97e1fb;\n",
       "    --link-hover: #00688e;\n",
       "}\n",
       "\n",
       "p.dataframe_description {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe {\n",
       "    font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n",
       "    font-size: 12px;\n",
       "    background-color: var(--background);\n",
       "    color: var(--text-color-dark);\n",
       "    border: none;\n",
       "    border-collapse: collapse;\n",
       "}\n",
       "\n",
       "table.dataframe th, td {\n",
       "    padding: 6px;\n",
       "    border: 1px solid transparent;\n",
       "    text-align: left;\n",
       "}\n",
       "\n",
       "table.dataframe th {\n",
       "    background-color: var(--background);\n",
       "    color: var(--header-text-color);\n",
       "}\n",
       "\n",
       "table.dataframe td {\n",
       "    vertical-align: top;\n",
       "}\n",
       "\n",
       "table.dataframe th.bottomBorder {\n",
       "    border-bottom-color: var(--bold-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:nth-child(odd) {\n",
       "    background: var(--background-odd);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:nth-child(even) {\n",
       "    background: var(--background);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:hover {\n",
       "    background: var(--background-hover);\n",
       "}\n",
       "\n",
       "table.dataframe a {\n",
       "    cursor: pointer;\n",
       "    color: var(--link-color);\n",
       "    text-decoration: none;\n",
       "}\n",
       "\n",
       "table.dataframe tr:hover > td a {\n",
       "    color: var(--link-color-pale);\n",
       "}\n",
       "\n",
       "table.dataframe a:hover {\n",
       "    color: var(--link-hover);\n",
       "    text-decoration: underline;\n",
       "}\n",
       "\n",
       "table.dataframe img {\n",
       "    max-width: fit-content;\n",
       "}\n",
       "\n",
       "table.dataframe th.complex {\n",
       "    background-color: var(--background);\n",
       "    border: 1px solid var(--background);\n",
       "}\n",
       "\n",
       "table.dataframe .leftBorder {\n",
       "    border-left-color: var(--inner-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe .rightBorder {\n",
       "    border-right-color: var(--inner-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe .rightAlign {\n",
       "    text-align: right;\n",
       "}\n",
       "\n",
       "table.dataframe .expanderSvg {\n",
       "    width: 8px;\n",
       "    height: 8px;\n",
       "    margin-right: 3px;\n",
       "}\n",
       "\n",
       "table.dataframe .expander {\n",
       "    display: flex;\n",
       "    align-items: center;\n",
       "}\n",
       "\n",
       "/* formatting */\n",
       "\n",
       "table.dataframe .null {\n",
       "    color: var(--text-color-pale);\n",
       "}\n",
       "\n",
       "table.dataframe .structural {\n",
       "    color: var(--text-color-medium);\n",
       "    font-weight: bold;\n",
       "}\n",
       "\n",
       "table.dataframe .dataFrameCaption {\n",
       "    font-weight: bold;\n",
       "}\n",
       "\n",
       "table.dataframe .numbers {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe td:hover .formatted .structural, .null {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe tr:hover .formatted .structural, .null {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "            </style>\n",
       "        </head>\n",
       "        <body>\n",
       "            \n",
       "<table class=\"dataframe\" id=\"df_-1660944383\"></table>\n",
       "\n",
       "<p class=\"dataframe_description\">DataFrame: rowsCount = 3, columnsCount = 6</p>\n",
       "        </body>\n",
       "        <script>\n",
       "            \n",
       "/*<!--*/\n",
       "call_DataFrame(function() { DataFrame.addTable({ cols: [{ name: \"<span title=\\\"untitled: Int\\\">untitled</span>\", children: [], rightAlign: true, values: [\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">1</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">2</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">3</span></span>\"] }, \n",
       "{ name: \"<span title=\\\"long: Double\\\">long</span>\", children: [], rightAlign: true, values: [\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">24.0</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">24.5</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">25.5</span></span>\"] }, \n",
       "{ name: \"<span title=\\\"lat: Double\\\">lat</span>\", children: [], rightAlign: true, values: [\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">54.9</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">55.0</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">54.5</span></span>\"] }, \n",
       "{ name: \"<span title=\\\"survivors: Int\\\">survivors</span>\", children: [], rightAlign: true, values: [\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">340000</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">340000</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">340000</span></span>\"] }, \n",
       "{ name: \"<span title=\\\"direction: String\\\">direction</span>\", children: [], rightAlign: false, values: [\"A\",\"A\",\"A\"] }, \n",
       "{ name: \"<span title=\\\"group: Int\\\">group</span>\", children: [], rightAlign: true, values: [\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">1</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">1</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">1</span></span>\"] }, \n",
       "], id: -1660944383, rootId: -1660944383, totalRows: 3 } ) });\n",
       "/*-->*/\n",
       "\n",
       "call_DataFrame(function() { DataFrame.renderTable(-1660944383) });\n",
       "\n",
       "\n",
       "        </script>\n",
       "        </html>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "val minard = DataFrame.readCSV(\"https://raw.githubusercontent.com/vincentarelbundock/Rdatasets/master/csv/HistData/Minard.troops.csv\")\n",
    "minard.head(3)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "certified-grass",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"4sradZ\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"mapping\":{\n",
       "},\n",
       "\"guides\":{\n",
       "\"color\":\"none\"\n",
       "},\n",
       "\"coord\":{\n",
       "\"name\":\"map\",\n",
       "\"flip\":false\n",
       "},\n",
       "\"data\":{\n",
       "\"survivors\":[340000.0,340000.0,340000.0,320000.0,300000.0,280000.0,240000.0,210000.0,180000.0,175000.0,145000.0,140000.0,127100.0,100000.0,100000.0,100000.0,100000.0,98000.0,97000.0,96000.0,87000.0,55000.0,37000.0,24000.0,20000.0,20000.0,20000.0,20000.0,20000.0,12000.0,14000.0,8000.0,4000.0,4000.0,4000.0,60000.0,60000.0,60000.0,40000.0,33000.0,33000.0,33000.0,30000.0,30000.0,28000.0,22000.0,22000.0,6000.0,6000.0,6000.0,6000.0],\n",
       "\"long\":[24.0,24.5,25.5,26.0,27.0,28.0,28.5,29.0,30.0,30.3,32.0,33.2,34.4,35.5,36.0,37.6,37.7,37.5,37.0,36.8,35.4,34.3,33.3,32.0,30.4,29.2,28.5,28.3,27.5,26.8,26.4,25.0,24.4,24.2,24.1,24.0,24.5,25.5,26.6,27.4,28.7,28.7,29.2,28.5,28.3,24.0,24.5,24.6,24.6,24.2,24.1],\n",
       "\"lat\":[54.9,55.0,54.5,54.7,54.8,54.9,55.0,55.1,55.2,55.3,54.8,54.9,55.5,55.4,55.5,55.8,55.7,55.7,55.0,55.0,55.3,55.2,54.8,54.6,54.4,54.3,54.2,54.3,54.5,54.3,54.4,54.4,54.4,54.4,54.4,55.1,55.2,54.7,55.7,55.6,55.5,55.5,54.2,54.1,54.2,55.2,55.3,55.8,55.8,54.4,54.4],\n",
       "\"direction\":[\"A\",\"A\",\"A\",\"A\",\"A\",\"A\",\"A\",\"A\",\"A\",\"A\",\"A\",\"A\",\"A\",\"A\",\"A\",\"A\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"R\",\"A\",\"A\",\"A\",\"A\",\"A\",\"A\",\"R\",\"R\",\"R\",\"R\",\"A\",\"A\",\"A\",\"R\",\"R\",\"R\"],\n",
       "\"group\":[1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,3.0,3.0,3.0,3.0,3.0,3.0]\n",
       "},\n",
       "\"ggsize\":{\n",
       "\"width\":800.0,\n",
       "\"height\":200.0\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[{\n",
       "\"aesthetic\":\"size\",\n",
       "\"range\":[1.0,20.0]\n",
       "},{\n",
       "\"aesthetic\":\"color\",\n",
       "\"values\":[\"#E1CBAE\",\"#232021\"]\n",
       "}],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "\"x\":\"long\",\n",
       "\"y\":\"lat\",\n",
       "\"color\":\"direction\",\n",
       "\"size\":\"survivors\",\n",
       "\"group\":\"group\"\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"path\",\n",
       "\"data\":{\n",
       "}\n",
       "}],\n",
       "\"theme\":{\n",
       "\"name\":\"minimal\",\n",
       "\"axis\":\"blank\",\n",
       "\"flavor\":\"solarized_light\"\n",
       "}\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"4sradZ\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();    \n",
       "   </script>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "letsPlot(minard.toMap()) +\n",
    "    geomPath {\n",
    "        x = \"long\"\n",
    "        y = \"lat\"\n",
    "        size = \"survivors\"\n",
    "        group = \"group\"\n",
    "        color = \"direction\"\n",
    "    } +\n",
    "    scaleSize(1 to 20) +\n",
    "    guides(color = \"none\") +\n",
    "    scaleColorManual(listOf(\"#E1CBAE\", \"#232021\")) +\n",
    "    coordMap() + \n",
    "//     themeVoid() +\n",
    "    themeMinimal() + theme(axis=\"blank\") +\n",
    "    flavorSolarizedLight() +\n",
    "    ggsize(800, 200)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Kotlin",
   "language": "kotlin",
   "name": "kotlin"
  },
  "language_info": {
   "codemirror_mode": "text/x-kotlin",
   "file_extension": ".kt",
   "mimetype": "text/x-kotlin",
   "name": "kotlin",
   "nbconvert_exporter": "",
   "pygments_lexer": "kotlin",
   "version": "1.8.20"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
